package com.suian.spring.task;

import com.suian.spring.aspect.LogAnnotationAspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
//开启定时任务
//@EnableScheduling
@Component
public class ScheduledTask {
    private static final Logger logger = LoggerFactory.getLogger(ScheduledTask.class);
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Scheduled(fixedRate = 5000)
    public void reportHeart() {
//        ("固定速率任务 - 当前时间: " + dateFormat.format(new Date()));
        logger.info("固定速率任务 - 当前时间: {}",dateFormat.format(new Date()));
    }
}
